/***************************************************************************
 *   Copyright (C) 2008, 2009 by MJ   *
 *   hanfman_cool@web.de   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

//mani.cpp - is a part from steamserverutil by MJ
//steamserverutil.googlecode.com

//mani.cpp handles the functions for the mani admin plugin

#include <iostream> //for cout and cin
#include <fstream> //for ifstream and ofstream
#include <stdlib.h> //for system()
#include <vector>

//for gettext
#include <libintl.h>
#include <locale.h>

#define _(STRING) gettext(STRING)

//#include "mani.h"
#include "steamserverutil.h"
#include "conf_server.h"


//to make the differance of the arrays better 
#define OFF_N 0
#define OFF_C 1



using namespace std;

//function which tests if the server is really installed, if it is installed it saves the path in the char param[]
void mani_test(unsigned short int choice)
{
	if (choice > 5)
	{
		cout << _("\n\nServer is not supported by mani admin plugin!!\n\n");
		return;
	}
	
	if (choice == 3) //gmod
		cout << _("\n\nNote that this server isn't officially supported by mani admin plugin\n");
	
	param = workdir;
	
	switch(choice)
	{
		case 1:	if(server_css==true)
		{
						
			param += "/servers_source/cstrike";
			installed = true;
		}
		else
			not_installed();
		break;
		case 2:	if(server_dods==true)
		{
			param +=  "/servers_source/dod";
											
				
			installed = true;
		}
		else
			not_installed();
		break;
		case 3:	if(server_garrysmod==true)
		{
			param +=  "/servers_source/garrysmod";
						
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 4:	if(server_hl2mp==true)
		{
			param +=  "/servers_source/garrysmod";
						
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 5:	if(server_tf==true)
		{	
			param +=  "/servers_source/tf";
					
			installed = true;
		}
		else
			not_installed();
		break;
		default: cout << _("\n\nTry again ;)\n\n");
		break;
	}
}

void install_mani()
{
	cout << _("\n\nIn which server do you want to install mani admin plugin?\n\n");

	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	string params; //the hole command is saved here



	params = "cd "; //because in function mani_test the "cd " is not included
	param.clear();

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------(modified)


	if(installed==true)
	{
		if (server[choice]==5)
		{
			
			cout << endl << endl << _("Downloading mani admin plugin with wget, unzipping archive...") << endl << endl;
			params += " && wget http://steamserverutil.googlecode.com/files/mani_admin_plugin_v1_2_beta_s_orange.zip && ";
			

			//to download mani admin plugin


			params += "unzip -o mani_admin_plugin_v1_2_beta_s_orange.zip ";
			//to unzip mani amdin plugin (unzips automatically in right folder)

			system_check(system(params.c_str()));
		}
		else
		{
			cout << endl << endl << _("Downloading mani admin plugin with wget, unzipping archive...") << endl << endl;
			params += " && wget http://steamserverutil.googlecode.com/files/mani_admin_plugin_v1_2_beta_s.zip && ";

			//to download mani admin plugin



			params += "unzip -o mani_admin_plugin_v1_2_beta_s.zip ";
			//to unzip mani amdin plugin (unzips automatically in right folder)

			system_check(system(params.c_str()));

		}


		cout << params;

		ofstream save_vdf;

		cout << _("\n\nCreating mani_admin_plugin.vdf\n");
		
		param += "/addons/mani_admin_plugin.vdf";
		
		save_vdf.open(param.c_str()); //right path
		
		//with choice right entry
		switch (server[choice])
		{

			case 1: 
				
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../cstrike/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;

			case 2: 
				
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../dod/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;
				
			case 3: 
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../garrysmod/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				
				save_vdf.close();
				
				
				//param[strlen(param.c_str()) - 29] = /*to delete old path, see above*/ 
				param.erase(param.size() - 29, param.size());
				param += "/cfg/server.cfg";
				
				save_vdf.open(param.c_str(), ios_base::app);
				
				save_vdf << "\n\nexec mani_server\n"; //needed otherwise gmod can not handle mani admin plugin
				break;

			case 4: 
		
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../hl2mp/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;

			case 5:
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../tf/addons/mani_admin_plugin\"\n";
				save_vdf << "}"; 
				break;



				default: never_happen();
				break;

		}
		
		save_vdf.close();


		cout << _("\n\nMani Admin Plugin succesfully installed!\n");
			
	}
}

void install_quake()
{
	cout << _("\n\nIn which server do you want to install the quake sound pack?\n\n");

	

	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	string params; //the hole command is saved here





	params = "cd "; //because in function mani_test the "cd " is not included

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------(modified)
	
	//we dont need this, because the line is always in mani_server.cfg
	//char cfg_dir[200];
	//strcpy(cfg_dir ,param); //to add the required line to mani_server.cfg


	if(installed==true)
	{
		
			
		cout << endl << endl << _("Downloading quake sound pack with wget, unzipping archive...") << endl << endl;
		params += " && wget http://steamserverutil.googlecode.com/files/quake_pack.zip && ";

			//to download mani admin plugin


		params += "unzip -o quake_pack.zip ";
			//to unzip mani amdin plugin (unzips automatically in right folder)
			
		system_check(system(params.c_str()));
			
		cout << _("\n\nquake sound pack succesfully installed!\n\n");

	}	
	
}

void deactivate_mani()
{
	cout << _("\n\nFrom which server do you wish to deactivate the mani admin plugin? \n");
	
	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	string params;


	params += "cd "; //the "cd " is not include by mani_test(int)
	
	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------(modified)


	

	if(installed==true)
	{
		cout << _("\n\nDeactivating mani admin plugin...\nDeleting mani_admin_plugin.vdf");
		params += " && rm -rf addons/mani_admin_plugin.vdf";


		system_check(system(params.c_str()));
	}


}


void mani_admins()
{
	bool exit = false;


	string params;

	cout << _("\n\nFrom which server do you want to manage the admins?\n");
	
	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------

	if(installed==true)
	{

		//copy old adminlist to the new one!
		
		temp = "cd " + params + " && " + "cp cfg/mani_admin_plugin/adminlist.txt.old cfg/mani_admin_plugin/adminlist.txt";
		
		system_check(system(temp.c_str()));

		params += "/cfg/mani_admin_plugin/adminlist.txt";

		cout << endl << endl;

		while (!exit)
		{


			
			vector<string> input[2]; //OFF_N = 0 means name; OFF_C = 1 means steam id or ip
			
			ifstream in;
			in.open(params.c_str());


			int counter = 0;

			if(in.is_open())
			{

				cout << _("\n\nCurrent admins: \n");
				
				while(!in.eof())
				{
					

					getline(in, temp);


				
					switch(temp[0])
					{
						case 'S': if(!temp.compare(0, 5, "STEAM"))
								input[OFF_C].push_back(temp);
						
						else
							cout << _("\n\nCannot understand: ") << temp << _("\nIgnoring...");

						break;
						
						case ';': input[OFF_C].push_back(temp);
						break;
						case '/': if(!temp.compare(0, 5, "//n: "))
						{
							input[OFF_N].push_back(&temp[5]);
							cout << (counter+1) << ".\t" << input[OFF_N].at(counter) << endl;
							counter++;
						}
						break;
						default: 
							if(temp[0] == 10 || temp[0]== 0) //10 means new line 0 means end of string
							{
								//nothing to do
							}
							else
								cout << _("\n\nCannot understand: ") << temp << _("\nIgnoring");
					}
				}
			}
			else
			{
				cout << _("\nNo admins. Please add one\n");
			
			}
			in.close();


			cout << _("\n\n1. Add admin\n");
			cout << _("2. Delete admin\n");
			cout << _("3. Delete all admins\n");
			cout << _("4. Exit\n");
			cout << " : ";

			cin >> choice;
			cin.ignore();


			

			ofstream out;
			out.open(params.c_str(), ios_base::app);

			switch(choice)
			{
				case 1: 
					
					cout << _("\n\nSteam ID or IP of the player? ");
					getline(cin, temp);
					
					//test if steam id or ip
					if(!temp.compare(0, 5 , "STEAM"))
					{
						out << endl << temp << endl;
					}
					else
					{
						out << endl<< ";"<< temp << endl;
					}


					cout << _("\nName or steam account of the player? ");
					getline(cin, temp);
					out << "//n: " << temp;
					break;
				case 2: cout << _("\n\nWhich admin do you want do delete? ");
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << _("\nThis entry does not exist!\n\n");
					}
					else
					{

						ofstream save_del;
						save_del.open(params.c_str());


						input[OFF_N].erase(input[OFF_N].begin() + choice);
						input[OFF_C].erase(input[OFF_C].begin() + choice);


						//	   OFF_C and OFF_N should be same size
						for (int i = 0;i<input[OFF_N].size();i++)
						{
							save_del << endl << input[OFF_C][i] << endl;
							save_del << "//n: " << input[OFF_N][i];	
						}
						save_del.close();
					}
					break;
					case 3: char temp;
					cout << _("\n\nAll admins are going to be deleted. Are you sure?(y|n) ");
					cin >> temp;
				

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params.c_str());
						del_all.close();
					}
					break;
					case 4: exit=true;
					break;
					default: cout << _("\n\nTry again;)\n\n");
					break;
			}

			out.close();

		}
	}
}


void mani_wordfilter()
{
	bool exit=false;

	string params;

	cout << _("\n\nFrom which server do you want to manage the admins?\n");

	int choice = choose_dialog();
	
	if(choice == -1)
		return;


	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------



	if(installed==true)
	{


		params += "/cfg/mani_admin_plugin/wordfilter.txt";

		



		while(!exit)
		{

			int counter = 0;
			vector<string> filter;

			ifstream in;
			in.open(params.c_str());
		
			cout << _("\nhere is your wordfilter:  \n");

			if(in.is_open())
			{
				while (!in.eof())
				{
					

					getline(in, temp);

					switch(temp[0])
					{
						case '/': //nothing to do
							break;
						case 10: //nothing to do (10 means new line)
							break;
						case 0: //nothing to do (0 means end of string)
							break;
						case 13: break;
							default: filter.push_back(temp);
							cout << (counter + 1) << ".\t" << filter[counter] << endl;
							counter++; 
							break;
					}
				}
			}
			else
				cout << _("\nNo wordfilters. Please add one!\n");

			cout << _("\n\n1. Add word\n");
			cout << _("2. Delete word\n");
			cout << _("3. Delete complete wordfilter\n");
			cout << _("4. Exit\n");
			cout << " : ";
			cin >> choice;
			cin.ignore();

			switch (choice)
			{
				case 1: cout << _("\nWord: ");
				{
					
					getline(cin, temp);
					ofstream out;
					out.open(params.c_str(), ios_base::app);
					out << endl << temp;
					out.close();
				}
				break;


				case 2: cout << _("\n\nWhich word do you want do delete? ");
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << _("\nThis entry does not exist!\n\n");
				}
				else
				{

					ofstream save_del;
					save_del.open(params.c_str());
					
					
					filter.erase(filter.begin() + choice);

					for (int i = 0;i<filter.size();i++)
						save_del << endl << filter[i];
						
					save_del.close();
				}
				break;
				case 3: char temp;
				cout << _("\n\nThe hole wordfilter is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params.c_str());
					del_all.close();
				}
				break;
				case 4: exit=true;
				break;
				default: cout << _("\n\nTry again;)\n\n");
				break;
			}
		}
		
	}

}

void mani_rcon()
{


	string params;
	bool exit = false;

	cout << _("From which server do you wish to edit the rconlist?\n");

	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------

	
	//OFF_name means 0, OFF_C means 1	
	


	

	if(installed==true)
	{

	
		params += "/cfg/mani_admin_plugin/rconlist.txt";
		


		


		while (!exit)
		{

			unsigned short int counter = 0;
			
			vector<string> buf[2];
			
			ifstream in;
			in.open(params.c_str());

			if(in.is_open())
			{
			

				cout << _("\n\nCurrent rconlist: \n");


				while(!in.eof())
				{
					
					getline(in, temp);
				
					switch(temp[0])
					{
						case '"': int i;
						
						//force a new string in the vector
						buf[OFF_N].push_back("");
						buf[OFF_C].push_back("");
						
						for(i=1; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[OFF_N][counter] += temp[i];
						}

						buf[OFF_N][counter] += '\0'; //0 means end of string

						cout << (counter+1) << ".\t" << buf[OFF_N][counter] << endl;



						i+=2; //to junp over the '"' and over the ' '

						
						for(; i<temp.size(); i++)
						{
							if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i] == 0) //0 means end of string
								break;

							buf[OFF_C][counter] += temp[i];
						}

							  
						buf[OFF_C][counter] += '\0'; //0 means end of string

						counter++;
							  
						temp.clear(); //clearing, to avoid the bug with the letter when temp[] = "\"\" "
							  
						break;
						
						case 10: //10 means new line
							//nothing to do
							break;
						case 0://0 means end of string
							//nothing to do
								break;
						case '/': if (temp[1] == '/')
							break;

						default: buf[OFF_N].push_back(temp);
							buf[OFF_C].push_back(temp);
							 
							cout << (counter+1) << ".\t" << buf[OFF_N].at(counter) << endl;
							 
							counter++;
							
					}
				
				}

				in.close();

			}
		
			else
				cout << _("\nYou have no rcon commands, please add one!\n");

		
		

			cout << _("\n\n1. Add command\n");
			cout << _("2. Delete command\n");
			cout << _("3. Edit a command\n");
			cout << _("4. Add Surf Mod Option\n");
			cout << _("5. Delete hole list\n");
			cout << _("6. Exit\n");


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << _("\nCommand: ");
				{
					string command;
					getline(cin, command);

					cout << _("\nName: ");
					string name;
					getline(cin, name);

					ofstream out;
					out.open(params.c_str(), ios_base::app);
					out << endl << "\"" << name << "\"" << " " << command;
					out.close();
				}
				break;

			
				case 2: cout << _("\n\nWhich entry do you want do delete? ");
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << _("\nThis entry does not exist!\n\n");
				}
				else
				{

					ofstream save_del;
					save_del.open(params.c_str());

					buf[OFF_N].erase(buf[OFF_N].begin() + choice);
					buf[OFF_C].erase(buf[OFF_C].begin() + choice);

					//		OFF_C, OFF_N should be same size
					for (int i = 0;i<buf[OFF_C].size();i++)
						save_del << endl << "\"" << buf[OFF_N][i] << "\"" << " " << buf[OFF_C][i];
						
							
					
					save_del.close();
				}
				break;


				case 3:	cout << _("\nWhich entry do you wish do edit? ");
				cin >> choice;
					
				choice--; //for thr right array


				if (choice >= counter)
				{
					cout << _("\n\nThis entry does not exist!\n\n");
				}
				else
				{
					cout << _("\n\n1. Edit the Name\n");
					cout << _("2. Edit the command\n");
					cout << " : ";
					unsigned short int temp_e;
					cin >> temp_e;
					cin.ignore();

					if(temp_e > 2)
					{
						cout << _("\n\nWrong choice!\n");
					}
					else
					{
						temp_e--;  //for the right array
						cout << _("\nNew name/command: ");
						getline(cin, buf[temp_e][choice]);

	

						ofstream save_edit;
						save_edit.open(params.c_str());


						//		OFF_C, OFF_N should be same size
						for (int i = 0;i<buf[OFF_N].size();i++)
							save_edit  << "\"" << buf[OFF_N][i] << "\"" << " " << buf[OFF_C][i] << endl;

				
						
					}

				}

				break;

				case 4: {
					ofstream surf;
					surf.open(params.c_str(), ios_base::app);

					surf << "\n\"Surf Mod On\" sv_airaccelerate 2000\n";
					surf << "\"Surf Mod Off\" sv_airaccelerate 1";
					surf.close();


				}
				cout << _("\nSucces!\n");
				break;

				case 5: char temp;
				cout << _("\n\nThe hole rconlist is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params.c_str());
					del_all.close();
				}
				break;
				case 6: exit = true;
				break;
				default: cout << _("\n\nTry again;)\n");
			}
		}
	}
}

		
void mani_votequestionlist()
{
	string params;
	bool exit = false;

	cout << _("From which server do you wish to edit the votequestionlist?\n");

	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	
	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------

	


	

	if(installed==true)
	{

	
		params += "/cfg/mani_admin_plugin/votequestionlist.txt";
		

		

		while (!exit)
		{
			
			vector<string> buf[2]; //OFF_name means 0, OFF_C means 1	
			unsigned short int counter = 0;

			ifstream in;
			in.open(params.c_str());

			if(in.is_open())
			{
				cout << _("\n\nCurrent votequestionlist: \n");


				while(!in.eof())
				{
					
					getline(in, temp);
				
					switch(temp[0])
					{
						case '"': int i;
						
						//force a new string in the vector
						buf[OFF_N].push_back("");
						buf[OFF_C].push_back("");
						
						for(i=1; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[OFF_N][counter] += temp[i];
						}
							  
						buf[OFF_N][counter] += '\0'; //0 means end of string

						cout << (counter+1) << ".\t" << buf[OFF_N][counter] << endl;

							 

						i+=3; //to junp over the '"' and over the ' ' and the second '"'

						
						for(; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[OFF_C][counter] += temp[i];
						}

							  
						buf[OFF_C][counter] += '\0'; //0 means end of string

							 // cout << buf[0][OFF_C] << " "  << buf[1][OFF_C];

						counter++;
							  
						temp.clear(); //clearing to avoid the bug with the letter when temp[] = "\"\" "
							  
						break;
			

							
					}
				
				}

				in.close();
			}
		
			else
				cout << _("\nYou have no votequestions, please add one!\n");






			cout << _("\n\n1. Add question\n");
			cout << _("2. Delete a question\n");
			cout << _("3. Edit a question\n");
			cout << _("4. Delete hole list\n");
			cout << _("5. Exit\n");


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << _("\nQuestion: ");
				{
					string question;
					getline(cin, question);

					cout << _("\nName: ");
					string name;
					getline(cin, name);

					ofstream out;
					out.open(params.c_str(), ios_base::app);
					out << endl << "\"" << name << "\"" << " \"" << question << "\"";
					out.close();
				}
				break;

			
				case 2: cout << _("\n\nWhich entry do you want do delete? ");
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << _("\nThis entry does not exist!\n\n");
				}
				else
				{

					ofstream save_del;
					save_del.open(params.c_str());

					buf[OFF_C].erase(buf[OFF_C].begin() + choice);
					buf[OFF_N].erase(buf[OFF_N].begin() + choice);

					for (int i = 0;i<buf[OFF_N].size();i++)
						save_del << endl << "\"" << buf[OFF_N][i] << "\"" << " \"" << buf[OFF_C][i] << "\"";
					
					save_del.close();
				}
				break;


				case 3:	cout << _("\nWhich entry do you wish do edit? ");
				cin >> choice;
					
				choice--; //for the right array


				if (choice < counter)
				{
					cout << _("\n\nThis entry does not exist!\n\n");
				}
				else
				{
					cout << _("\n\n1. Edit the Name\n");
					cout << _("\n\n2. Edit the question\n");
					cout << " : ";
					unsigned short int temp_e;
					cin >> temp_e;

					if(temp_e > 2)
					{
						cout << _("\n\nWrong choice!\n");
					}
					else
					{
						temp_e--;  //for the right array
						cout << _("\nNew name/question: ");
						getline(cin, buf[choice][temp_e]);

	

						ofstream save_edit;
						save_edit.open(params.c_str());




						for (int i = 0;i<buf[OFF_N].size();i++)
							save_edit  << "\"" << buf[OFF_N][i] << "\"" << " \"" << buf[OFF_C][i] << "\"" << endl;

				
						
					}

				}

				break;

				case 4: char temp;
				cout << _("\n\nThe hole votequestionlist is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params.c_str());
					del_all.close();
				}
				break;
				case 5: exit = true;
				break;
				default: cout << _("\n\nTry again;)\n");
				break;
		
			} //switch

		}//while(!exit)




	}//if(installed=true)
}




void mani_ping_reserve(int x)
{
	bool exit = false;


	//x = 1 means reserveslots, x = 2 means pingimmunity

	string params;

	cout << _("\n\nFrom which server do you want to manage the ");
	
	if(x==1)
		cout << _("reserveslots?\n");
	else
		cout << _("pingimmunity\n");
	
	
	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------


	if(installed==true)
	{

		if(x==1)
			params += "/cfg/mani_admin_plugin/reserveslots.txt";
		else
			params += "/cfg/mani_admin_plugin/pingimmunity.txt";

		cout << endl << endl;

		while (!exit)
		{


			vector<string> input[2]; //OFF_N = 0 means name; OFF_C = 1 means steam id or ip
			
			ifstream in;
			in.open(params.c_str());


			int counter = 0;

			if(in.is_open())
			{

				cout << _("\n\nCurrent ");
				
				if(x==1)
					cout << _("reserveslots: \n");
				else
					cout << _("pingimmunities: \n");
				
				while(!in.eof())
				{
					

					getline(in, temp);


				
					switch(temp[0])
					{
						case 'S': if(!temp.compare(0, 5, "STEAM"))
						{
							input[OFF_C].push_back(temp);
						}
						else
							cout << _("\n\nCannot understand: ") << temp << _("\nIgnoring...\n");

						break;
						
						case '/': if(!temp.compare(0, 5, "//n: "))
						{
							input[OFF_N].push_back(&temp[5]);
							cout << (counter+1) << ".\t" << input[OFF_N][counter] << endl;
							counter++;
						}
						break;
						default: 
							if(temp[0] == 10 || temp[0]== 0 || temp[0] == 13) //10 means new line 0 means end of string 13 means "\r"
							{
								//nothing to do
							}
							else
								cout << _("\n\nCannot understand: ") << temp << _("\nIgnoring..");

							break;
					}
	
					
				}
			}
			else
			{
				cout << _("\nNo entrys. Please add one\n");
			
			}
			in.close();


			cout << _("\n\n1. Add a person\n");
			cout << _("2. Delete a person\n");
			cout << _("3. Delete all persons\n");
			cout << _("4. Exit\n");
			cout << " : ";

			cin >> choice;
			cin.ignore();


			

			ofstream out;
			out.open(params.c_str(), ios_base::app);

			switch(choice)
			{
				case 1: 
					
					cout << _("\n\nSteam ID of the player? ");
					getline(cin, temp);
					
					out << endl << temp << endl;

					cout << _("\nName or steam account of the player? ");
					getline(cin, temp);
					out << "//n: " << temp;
					break;
				case 2: cout << _("\n\nWhich person do you want do delete? ");
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << _("\nThis entry does not exist!\n\n");
					}
					else
					{

						ofstream save_del;
						save_del.open(params.c_str());

						input[OFF_C].erase(input[OFF_C].begin() + choice);
						input[OFF_N].erase(input[OFF_N].begin() + choice);

						for (int i = 0;i<input[OFF_N].size();i++)
						{	
							save_del << endl << input[OFF_C][i] << endl;
							save_del << "//n: " << input[OFF_N][i];
							
						}
						save_del.close();
					}
					break;
					case 3: char temp;
					cout << _("\n\nAll persons are going to be deleted. Are you sure?(y|n) ");
					cin >> temp;
				

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params.c_str());
						del_all.close();
					}
					break;
					case 4: exit=true;
					break;
					default: cout << _("\n\nTry again;)\n\n");
					break;
			}

			out.close();

		}
	}
}

void mani_resw()
{
	cout << _("\n\nThis option is only supported by the Counter Strike Source Server\n");

	installed = true;	
	server_path(1 /*css*/);
	if(!installed)
		return;

	bool exit = false;

	while(!exit)
	{


		ifstream in;
		param = workdir + "/servers_source/cstrike/cfg/mani_admin_plugin/default_weapon_restrict.txt";
		

		in.open(param.c_str());

		int counter = 0;
		vector<string> resw;

		cout << _("\nCurrent restricted weapons: \n\n");

		if (in.is_open())
		{
			while(!in.eof())
			{
				
				getline(in, temp);
				
				if(temp[0] == '/' && temp[1] == '/')
					continue;

				if(temp[0] == 10 || temp[0]== 0 || temp[0] == 13) //10 means new line 0 means end of string 13 means "\r"
					continue;

				

				if(!temp.compare(0, 3, "awp"))
					cout << (counter+1) << ".\tMagnum Sniper Rifle(awp)\n";

				if(!temp.compare(0, 5, "g3sg1"))
					cout << (counter+1) << ".\tD3/AU1\n";

				if(!temp.compare(0, 5, "sg550"))
					cout << (counter+1) << ".\tKrieg 550 Commando\n";

				if(!temp.compare(0, 5, "galil"))
					cout << (counter+1) << ".\tIDF Defender(galil)\n";

				if(!temp.compare(0, 4, "ak47"))
					cout << (counter+1) << ".\tCV-47(AK-47)\n";
				
				if(!temp.compare(0, 5, "scout"))
					cout << (counter+1) << ".\tSchmidt Scout\n";

				if(!temp.compare(0, 5, "sg552"))
					cout << (counter+1) << ".\tKrieg 552\n";

				if(!temp.compare(0, 5, "famas"))
					cout << (counter+1) << ".\tClarion 5.56(famas)\n";

				if(!temp.compare(0, 4 , "m4a1"))
					cout << (counter+1) << ".\tMaverick M4A1 Carbine(m4a1)\n";	

				if(!temp.compare(0, 3, "aug"))
					cout << (counter+1) << ".\tBullpup\n";

				if(!temp.compare(0, 5, "glock"))
					cout << (counter+1) << ".\t9x19mm Sidearm(glock)\n";

				if(!temp.compare(0, 3, "usp"))
					cout << (counter+1) << ".\tKM .45 Tactical(usp)\n";

				if(!temp.compare(0, 4, "p228"))
					cout << (counter+1) << ".\t228 Compact\n";

				if(!temp.compare(0, 6, "deagle"))
					cout << (counter+1) << ".\tNight Hawk .50C(deagle)\n";

				if(!temp.compare(0, 5, "elite"))
					cout << (counter+1) << ".\t.40 Dual Elites\n";

				if(!temp.compare(0, 9, "fiveseven"))
					cout << (counter+1) << ".\tES Five//Seven\n";

				if(!temp.compare(0, 2, "m3"))
					cout << (counter+1) << ".\tLeone 12 Gauge Super(m3)\n";

				if(!temp.compare(0, 6, "xm1014"))
					cout << (counter+1) << ".\tLeone YG1265 Auto Shotgun\n";

				if(!temp.compare(0, 5, "mac10"))
					cout << (counter+1) << ".\tIngram MAC-10\n";

				if(!temp.compare(0, 3, "tmp"))
					cout << (counter+1) << ".\tSchmidt Machine Pistol(tmp)\n";

				if(!temp.compare(0, 7, "mp5navy"))
					cout << (counter+1) << ".\tKM Sub-Machine Gun(mp5)\n";

				if(!temp.compare(0, 5, "ump45"))
					cout << (counter+1) << ".\tKM UMP45\n";

				if(!temp.compare(0, 4, "p90"))
					cout << (counter+1) << ".\tES C90\n";

				if(!temp.compare(0, 4, "m249"))
					cout << (counter+1) << ".\tM249\n";

				if(!temp.compare(0, 9, "flashbang"))
					cout << (counter+1) << ".\tFlashbang\n";

				if(!temp.compare(0, 9, "hegrenade"))
					cout << (counter+1) << ".\tHE Grenade\n";

				if(!temp.compare(0, 12, "smokegrenade"))
					cout << (counter+1) << ".\tSmoke Grenade\n";

				
				resw.push_back(temp);

				counter++;
			}
		}
		else
			cout << _("No restricted weapons found. Please add one");


		cout << _("\n\n1. Add a weapon\n");
		cout << _("2. Delete a waepon\n");
		cout << _("3. Delete all\n");
		cout << _("4. Exit\n");
		cout << " : ";
		unsigned short int choice;

		cin >> choice;

		switch(choice)
		{
			case 1: 


				


				cout << _("\n\nWhich weapon should be restricted?\n\n");

				cout << "1.  Magnum Sniper Rifle(awp)\n";
				cout << "2.  D3/AU1\n";
				cout << "3.  Krieg 550 Commando\n";
				cout << "4.  IDF Defender\n";
				cout << "5.  CV-47(AK -47)\n";
				cout << "6.  Schmidt Scout\n";
				cout << "7.  Krieg 552\n";
				cout << "8.  Clarion 5.56(famas)\n";
				cout << "9.  Maverick M4A1 Carbine(m4a1)\n";
				cout << "10. Bullpup\n";
				cout << "11. 9x19mm Sidearm(glock)\n";
				cout << "12. KM .45 Tactical(usp)\n";
				cout << "13. 228 Compact\n";
				cout << "14. Night Hawk .50C(deagle)\n";
				cout << "15. .40 Dual Elites\n";
				cout << "16. ES Five//Seven\n";
				cout << "17. Leone 12 Gauge Super(m3)\n";
				cout << "18. Leone YG1265 Auto Shotgun\n";
				cout << "19. Ingram MAC-10\n";
				cout << "20. Schmidt Machine Pistol(tmp)\n";
				cout << "21. KM Sub-Machine Gun(mp5)\n";
				cout << "22. KM UMP45\n";
				cout << "23. ES C90\n";
				cout << "24. M249\n";
				cout << "25. Flashbang\n";
				cout << "26. HE Grenade\n";
				cout << "27. Smoke Grenade\n";

				cout << " : ";
				cin >> choice;

				

				{
					ofstream add;
					add.open(param.c_str(), ios_base::app);
				
					switch(choice)
					{
						case 1: add << endl << "awp";
						break;
						case 2: add << endl << "g3sg1";
						break;
						case 3: add << endl << "sg550";
						break;
						case 4: add << endl << "galil";
						break;
						case 5: add << endl << "ak47";
						break;
						case 6: add << endl << "scout";
						break;
						case 7: add << endl << "sg552";
						break;
						case 8: add << endl << "famas";
						break;
						case 9: add << endl << "m4a1";
						break;
						case 10: add << endl << "aug";
						break;
						case 11: add << endl << "glock";
						break;
						case 12: add << endl << "usp";
						break;
						case 13: add << endl << "p228";
						break;
						case 14: add << endl << "deagle";
						break;
						case 15: add << endl << "elite";
						break;
						case 16: add << endl << "fiveseven";
						break;
						case 17: add << endl << "m3";
						break;
						case 18: add << endl << "xm1014";
						break;
						case 19: add << endl << "mac10";
						break;
						case 20: add << endl << "tmp";
						break;
						case 21: add << endl << "mp5navy";
						break;
						case 22: add << endl << "ump45";
						break;
						case 23: add << endl << "p90";
						break;
						case 24: add << endl << "m249";
						break;
						case 25: add << endl << "flashbang";
						break;
						case 26: add << endl << "hegrenade";
						break;
						case 27: add << endl << "smokegrenade";
						break;
						default: cout << _("\nWrong choice!\n\n");
					}

					add.close();

				}

				break;
				case 2: cout << _("\n\nWhich entry do you wish to delete? ");
				cin >> choice;

				choice--;

				if(choice >= counter)
					cout << _("\n\nEntry does not exist!\n");

				else
				{
					ofstream out;
					out.open(param.c_str());

					resw.erase(resw.begin() + choice);
					
					for(int i = 0; i<resw.size(); i++)
						out << resw[i] << endl;
					
					out.close();
				}
				break;
				case 3: char temp;
				cout << _("\n\nThe hole voterconlist is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
				

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(param.c_str());
					del_all.close();
				}
				break;
				case 4: exit =true;
				break;
				default: cout << _("\n\nTry again ;)\n");
		}



	}
}


void mani_voterconlist()
{
	
	string params;
	bool exit = false;

	cout << _("From which server do you wish to edit the rconlist?\n");

	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------

	





	if(installed==true)
	{

	
		
		params += "/cfg/mani_admin_plugin/voterconlist.txt";
		


		


		while (!exit)
		{
			vector<string> buf[3]; //OFF_name means 0, OFF_C menas 1, 2 is the question
			unsigned short int counter = 0;

			ifstream in;
			in.open(params.c_str());

			if(in.is_open())
			{
			

				cout << _("\n\nCurrent voterconlist: \n");


				while(!in.eof())
				{
					
					getline(in, temp);
				
					switch(temp[0])
					{
						case '"': int i;
						
						//force new string in vector
						buf[OFF_N].push_back("");
						buf[OFF_C].push_back("");
						buf[2].push_back("");
						//  2 means question
						
						for(i=1; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[OFF_N][counter] += temp[i];
						}
							  
						buf[OFF_N][counter] += '\0'; //0 means end of string
							  
						cout << (counter+1) << ".\t" << buf[OFF_N][counter] << endl;

							  

						i+=3; //to junp over the '"' and over the ' ' and the second '"'

						
						for(; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[2][counter] += temp[i];
						}

						i+=2; //to junp over the '"' and over the ' '

						
						for(; i<temp.size(); i++)
						{
							if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i]==0) //0 means end of string
								break;

							buf[OFF_C][counter] += temp[i];
						}

							 
						buf[OFF_C][counter] += '\0'; //0 means end of string
						buf[2][counter] += '\0'; //0 means end of string
						//  2 is space for the question

						counter++;
							  
						temp.clear(); //clearing to avoid the bug with the letter when temp[] = "\"\" "
							  
						break;
			

							
					}
				
				}

				in.close();

			}
		
			else
				cout << _("\nYou have no rcon questions, please add one!\n");

		
		

			cout << _("\n\n1. Add command\n");
			cout << _("2. Delete command\n");
			cout << _("3. Edit a command\n");
			cout << _("4. Delete hole list\n");
			cout << _("5. Exit\n");


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << _("\nCommand: ");
				{
					string command;
					getline(cin, command);

					cout << _("\nName: ");
					string name;
					getline(cin, name);

					cout << _("\nQuestion: ");
					string question;
					getline(cin, question);

					ofstream out;
					out.open(params.c_str(), ios_base::app);
					out << endl << "\"" << name << "\"" << " \"" << question << "\" " << command;
					out.close();
				}
				break;

			
				case 2: cout << _("\n\nWhich entry do you want do delete? ");
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << _("\nThis entry does not exist!\n\n");
				}
				else
				{

					ofstream save_del;
					save_del.open(params.c_str());


					buf[OFF_N].erase(buf[OFF_N].begin() + choice);
					buf[OFF_C].erase(buf[OFF_C].begin() + choice);
					buf[2].erase(buf[2].begin() + choice);
					//  2 stands for question
					
					for (int i = 0;i<buf[OFF_N].size();i++)
						save_del << endl << "\"" << buf[OFF_N][i] << "\"" << " \"" << buf[2][i] << "\" " << buf[OFF_C][i];

					
					
					save_del.close();
				}
				break;


				case 3:	cout << _("\nWhich entry do you wish do edit? ");
				cin >> choice;
					
				choice--; //for the right arry


				if (choice >= counter)
				{
					cout << _("\n\nThis entry does not exist!\n\n");
				}
				else
				{
					cout << _("\n\n1. Edit the Name\n");
					cout << _("2. Edit the command\n");
					cout << _("3. Edit the question\n");
					cout << " : ";
					unsigned short int temp_e;
					cin >> temp_e;

						

					if(temp_e > 3)
					{
						cout << _("\n\nWrong choice!\n");
					}
					else
					{

						temp_e--;  //for the right array
						cout << _("\nNew name/command/question: ");
						getline(cin, buf[temp_e][choice]);

	

						ofstream save_edit;
						save_edit.open(params.c_str());




						for (int i = 0;i<counter;i++)
							save_edit << "\"" << buf[OFF_N][i] << "\"" << " \"" << buf[2][i] << "\" " << buf[OFF_C][i] << endl;

				
						
					}

				}

				break;

				case 4: char temp;
				cout << _("\n\nThe hole voterconlist is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params.c_str());
					del_all.close();
				}
				break;
				case 5: exit = true;
				break;
				default: cout << _("\n\nTry again;)\n");
			}
		}
	}
}

void edit_manicfg(int i)//i == 1 -> mani_Server.cfg; i == 2 -> mani_quake_sounds.cfg
{
	cout << _("\n\nFrom which server do you wish to edit the ");
			
	if(i==1)
		cout << "mani_server.cfg?\n";
	else
		cout << "mani_quake_sounds.cfg?\n";
		
	int choice = choose_dialog();
	
	if(choice == -1)
		return;
	
	string params;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------
	
	if(i == 1)
		params += "/cfg/mani_server.cfg";
	else
		params += "/cfg/mani_quake_sounds.cfg";
	
	
	
	cout << _("\n\nWhich editor do you wish to edit the mani_server.cfg\n");
	cout << "1. Nano\n";
	cout << "2. Vim\n";
	cout << _("3. Specify Editor\n");
	cout << " : ";
	
	cin >> choice;
	cin.ignore();
	
	switch (choice)
	{
		case 1: param = "nano " + params;
		system_check(system(param.c_str()));
			//using param because it is more efficent
		break;
		case 2: param = "vim " + params;
		system_check(system(param.c_str()));
			//using param because it is more efficent
		break;
		case 3: cout << _("Command for the editor you want to use?(eg. nano, vim, kate, kwrite, gedit) ");
		
		cin >> temp;
		param = temp + " " + params;
		system_check(system(param.c_str()));
			//using param because it is more efficent
		break;
		default: cout << _("\n\nWrong choice!\n\n");
		break;
	}
}

void mani_sounds(int i)
{
	
	//1 means quakesoundlist.txt
	//2 means actionsoundlist.txt
	//3 means soundlist.txt



	string params;
	bool exit = false;

	
	cout << _("From which server do you wish to edit the ");
			
	
	if(i == 1)
		cout << "quakesoundlist?\n";
	if(i == 2)
		cout << "actionsoundlist?\n";
	if(i == 3)
		cout << "soundlist?\n";
	
	int choice = choose_dialog();
	
	if(choice == -1)
		return;

	//if it is really installed	
	installed = false;
	mani_test(server[choice]);
	params += param;
	//-------end---------

	


	

	if(installed==true)
	{

		if(i == 1)
			params += "/cfg/mani_admin_plugin/quakesoundlist.txt";
		
		if(i == 2)
			params += "/cfg/mani_admin_plugin/actionsoundlist.txt";
		
		if(i == 3)
			params += "/cfg/mani_admin_plugin/soundlist.txt";
		


		


		while (!exit)
		{

			unsigned short int counter = 0;

			
			vector<string> buf[2]; //OFF_name means 0, OFF_C means 1
			
			ifstream in;
			in.open(params.c_str());

			if(in.is_open())
			{
			

				cout << _("\n\nCurrent list: \n");


				while(!in.eof())
				{
					
					getline(in, temp);
				
					switch(temp[0])
					{
						case '"': int i;
						
						//force new string in vector
						buf[OFF_N].push_back("");
						buf[OFF_C].push_back("");
						
						for(i=1; i<temp.size(); i++)
						{
							if(temp[i]=='"')
								break;

							buf[OFF_N][counter] += temp[i];
						}

						buf[OFF_N][counter] += '\0'; //0 means end of string

						cout << (counter+1) << ".\t" << buf[OFF_N][counter] << endl;



						i++; //to junp over the '"' and over the ' '

						
						for(; i<temp.size(); i++)
						{
							if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i] == 0) //0 means end of string
								break;

							buf[OFF_C][counter] += temp[i];
						}

							  
						buf[OFF_C][counter] += '\0'; //0 means end of string

						counter++;
							  
						temp.clear(); //clearing to avoid the bug with the letter when temp[] = "\"\" "
							  
						break;
						
						case 10: //10 means new line
							//nothing to do
							break;
						case 13://13 means return ( '/r' )
							//nothing to do
							break;
						case '/': if (temp [1] == '/');
							else
							cout << _("\n\nCannot understand ") << temp << _("\nIgnoring..");
							break;
						case 0: break; //nothing to do, 0 means end of string

						default:cout << _("\n\nCannot understand ") << temp << _("\nIgnoring...\n");
							break;
							
					}

					
				
				}

				in.close();

			}
		
			else
				cout << _("\nYou have no sounds, please add one!\n");

		
		

			cout << _("\n\n1. Add sound\n");
			cout << _("2. Delete sound\n");
			cout << _("3. Edit a sound\n");
			cout << _("4. Delete hole list\n");
			cout << _("5. Exit\n");


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << _("\nPath: ");
				{
					string path;
					getline(cin, path);

					cout << _("\nName: ");
					string name;
					getline(cin, name);

					ofstream out;
					out.open(params.c_str(), ios_base::app);
					out << endl << "\"" << name << "\"" << " " << path;
					out.close();
				}
				break;

			
				case 2: cout << _("\n\nWhich entry do you want do delete? ");
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << _("\nThis entry does not exist!\n\n");
				}
				else
				{

					ofstream save_del;
					save_del.open(params.c_str());


					buf[OFF_C].erase(buf[OFF_C].begin() + choice);
					buf[OFF_N].erase(buf[OFF_N].begin() + choice);

					for (int i = 0;i<buf[OFF_N].size();i++)
						save_del << endl << "\"" << buf[OFF_N][i] << "\"" << " " << buf[OFF_C][i];
						
					save_del.close();
				}
				break;


				case 3:	cout << _("\nWhich entry do you wish do edit? ");
				cin >> choice;
					
				choice--; //for thr right array


				if (choice >= counter)
				{
					cout << _("\n\nThis entry does not exist!\n\n");
				}
				else
				{
					cout << _("\n\n1. Edit the Name\n");
					cout << _("2. Edit the path\n");
					cout << " : ";
					unsigned short int temp_e;
					cin >> temp_e;
					cin.ignore();

					if(temp_e > 2)
					{
						cout << _("\n\nWrong choice!\n");
					}
					else
					{
						temp_e--;  //for the right array
						cout << _("\nNew name/path: ");
						getline(cin, buf[temp_e][choice]);

	

						ofstream save_edit;
						save_edit.open(params.c_str());




						for (int i = 0;i<counter;i++)
							save_edit  << "\"" << buf[OFF_N][i] << "\"" << " " << buf[OFF_C][i] << endl;

				
						
					}

				}

				break;

				case 4: char temp;
				cout << _("\n\nThe hole list is going to be deleted. Are you sure?(y|n) ");
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params.c_str());
					del_all.close();
				}
				break;
				case 5: exit = true;
				break;
				default: cout << _("\n\nTry again;)\n");
			}
		}
	}
}



void config_mani()
{

	bool exit = false;

	while(!exit)
	{
		cout << _("\n\n1.  Install mani admin plugin\n");
		cout << _("2.  Install quake sound pack\n");
		cout << _("3.  Deactivate mani admin plugin\n");
		cout << _("4.  Configure Admins\n");
		cout << _("5.  Configure votemapslist\n");
		cout << _("6.  Configure wordfilter\n");
		cout << _("7.  Configure rconlist\n");
		cout << _("8.  Configure votequestionlist\n");
		cout << _("9.  Configure reserveslots\n");
		cout << _("10. Configure pingimmunities\n");
		cout << _("11. Configure restricted weapons\n");
		cout << _("12. Configure voterconlist\n");
		cout << _("13. Edit mani_server.cfg (main config for mani admin plugin)\n");
		cout << _("14. Edit mani_quake_sounds.cfg (main config for the quake sounds)\n");
		cout << _("15. Configure quake sounds\n");
		cout << _("16. Configure actionsoundlist\n");
		cout << _("17. Configure soundlist\n");
		cout << _("18. Exit\n");
		cout << " : ";

		unsigned short int choice;
		cin >> choice;
		cin.ignore();

		switch (choice)
		{
			case 1: install_mani();
			break;
			case 2: install_quake();
			break;
			case 3:	deactivate_mani();
			break;
			case 4: mani_admins();
			break;
			case 5: edit_mapcl(3); //3 means votemaplist.txt
			break;
			case 6: mani_wordfilter();
			break;
			case 7: mani_rcon();
			break;
			case 8: mani_votequestionlist();
			break;
			case 9: mani_ping_reserve(1); //1 means reserveslots
			break;
			case 10: mani_ping_reserve(2); //2 means pingimmunity
			break;
			case 11: mani_resw();
			break;
			case 12: mani_voterconlist();
			break;
			case 13: edit_manicfg(1); //1 means mani_server.cfg
			break;
			case 14: edit_manicfg(2); //2 means mani_quake_sounds.cfg
			break;
			case 15: mani_sounds(1); //1 means quakesoundlist.txt
			break;
			case 16: mani_sounds(2); //2 means actionsoundlist.txt
			break;
			case 17: mani_sounds(3); //3 means soundlist.txt
			break;
			case 18: exit = true;
			break;
			default: cout << _("\n\nTry again;)\n");
		}
	}
}
